30cc003038b6cc2675e5af611e506c4cddcd756e,enabler/src/de/schildbach/pte/AbstractEfaProvider.java,AbstractEfaProvider,queryTrips,#String#InputStream#,2177

Before Change


        }
        if (XmlPullUtil.test(pp, "itdPrintConfiguration"))
            XmlPullUtil.next(pp);
        if (XmlPullUtil.test(pp, "itdAddress"))
            XmlPullUtil.next(pp);

        List<Location> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
        Location from = null, via = null, to = null;

        while (XmlPullUtil.test(pp, "itdOdv")) {
            final String usage = XmlPullUtil.attr(pp, "usage");

            final List<Location> locations = new ArrayList<Location>();
            final String nameState = processItdOdv(pp, usage, new ProcessItdOdvCallback() {
                @Override
                public void location(final String nameState, final Location location, final int matchQuality) {
                    locations.add(location);
                }
            });

            if ("list".equals(nameState)) {
                if ("origin".equals(usage))
                    ambiguousFrom = locations;
                else if ("via".equals(usage))
                    ambiguousVia = locations;
                else if ("destination".equals(usage))
                    ambiguousTo = locations;
                else
                    throw new IllegalStateException("unknown usage: " + usage);
            } else if ("identified".equals(nameState)) {
                if ("origin".equals(usage))
                    from = locations.get(0);
                else if ("via".equals(usage))
                    via = locations.get(0);
                else if ("destination".equals(usage))
                    to = locations.get(0);
                else
                    throw new IllegalStateException("unknown usage: " + usage);
            } else if ("notidentified".equals(nameState)) {
                if ("origin".equals(usage))
                    return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_FROM);
                else if ("via".equals(usage))
                    return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_VIA);
                else if ("destination".equals(usage))
                    return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_TO);
                else
                    throw new IllegalStateException("unknown usage: " + usage);
            }
        }

        if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null)
            return new QueryTripsResult(header, ambiguousFrom, ambiguousVia, ambiguousTo);

        XmlPullUtil.optSkip(pp, "itdAddOdvSeq");
        XmlPullUtil.enter(pp, "itdTripDateTime");
        XmlPullUtil.enter(pp, "itdDateTime");
        XmlPullUtil.require(pp, "itdDate");
        if (!pp.isEmptyElementTag()) {
            XmlPullUtil.enter(pp, "itdDate");
            if (XmlPullUtil.test(pp, "itdMessage")) {
                final String message = XmlPullUtil.nextText(pp, null, "itdMessage");

                if ("invalid date".equals(message))
                    return new QueryTripsResult(header, QueryTripsResult.Status.INVALID_DATE);
                else
                    throw new IllegalStateException("unknown message: " + message);
            }
            XmlPullUtil.skipExit(pp, "itdDate");
        } else {
            XmlPullUtil.next(pp);
        }
        XmlPullUtil.skipExit(pp, "itdDateTime");
        XmlPullUtil.skipExit(pp, "itdTripDateTime");

        XmlPullUtil.requireSkip(pp, "itdTripOptions");
        while (XmlPullUtil.test(pp, "omcTaxi"))
            XmlPullUtil.requireSkip(pp, "omcTaxi");

        final List<Trip> trips = new ArrayList<Trip>();

        XmlPullUtil.require(pp, "itdItinerary");
        if (!pp.isEmptyElementTag()) {
            XmlPullUtil.enter(pp, "itdItinerary");

            XmlPullUtil.optSkip(pp, "itdLegTTs");

            if (XmlPullUtil.test(pp, "itdRouteList")) {
                XmlPullUtil.enter(pp, "itdRouteList");

                final Calendar calendar = new GregorianCalendar(timeZone);

                while (XmlPullUtil.test(pp, "itdRoute")) {
                    final String id;
                    if (useRouteIndexAsTripId) {
                        final String routeIndex = XmlPullUtil.optAttr(pp, "routeIndex", null);
                        final String routeTripIndex = XmlPullUtil.optAttr(pp, "routeTripIndex", null);
                        if (routeIndex != null && routeTripIndex != null)
                            id = routeIndex + "-" + routeTripIndex;
                        else
                            id = null;
                    } else {
                        id = null;
                    }
                    final int numChanges = XmlPullUtil.intAttr(pp, "changes");
                    XmlPullUtil.enter(pp, "itdRoute");

                    while (XmlPullUtil.test(pp, "itdDateTime"))
                        XmlPullUtil.next(pp);
                    if (XmlPullUtil.test(pp, "itdMapItemList"))
                        XmlPullUtil.next(pp);

                    XmlPullUtil.enter(pp, "itdPartialRouteList");
                    final List<Trip.Leg> legs = new LinkedList<Trip.Leg>();

After Change


            XmlPullUtil.next(pp);
        }
        XmlPullUtil.optSkip(pp, "itdPrintConfiguration");
        XmlPullUtil.optSkip(pp, "itdAddress");

        List<Location> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
        Location from = null, via = null, to = null;

        while (XmlPullUtil.test(pp, "itdOdv")) {
            final String usage = XmlPullUtil.attr(pp, "usage");

            final List<Location> locations = new ArrayList<Location>();
            final String nameState = processItdOdv(pp, usage, new ProcessItdOdvCallback() {
                @Override
                public void location(final String nameState, final Location location, final int matchQuality) {
                    locations.add(location);
                }
            });

            if ("list".equals(nameState)) {
                if ("origin".equals(usage))
                    ambiguousFrom = locations;
                else if ("via".equals(usage))
                    ambiguousVia = locations;
                else if ("destination".equals(usage))
                    ambiguousTo = locations;
                else
                    throw new IllegalStateException("unknown usage: " + usage);
            } else if ("identified".equals(nameState)) {
                if ("origin".equals(usage))
                    from = locations.get(0);
                else if ("via".equals(usage))
                    via = locations.get(0);
                else if ("destination".equals(usage))
                    to = locations.get(0);
                else
                    throw new IllegalStateException("unknown usage: " + usage);
            } else if ("notidentified".equals(nameState)) {
                if ("origin".equals(usage))
                    return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_FROM);
                else if ("via".equals(usage))
                    return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_VIA);
                else if ("destination".equals(usage))
                    return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_TO);
                else
                    throw new IllegalStateException("unknown usage: " + usage);
            }
        }

        if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null)
            return new QueryTripsResult(header, ambiguousFrom, ambiguousVia, ambiguousTo);

        XmlPullUtil.optSkip(pp, "itdAddOdvSeq");
        XmlPullUtil.enter(pp, "itdTripDateTime");
        XmlPullUtil.enter(pp, "itdDateTime");
        XmlPullUtil.require(pp, "itdDate");
        if (!pp.isEmptyElementTag()) {
            XmlPullUtil.enter(pp, "itdDate");
            if (XmlPullUtil.test(pp, "itdMessage")) {
                final String message = XmlPullUtil.nextText(pp, null, "itdMessage");

                if ("invalid date".equals(message))
                    return new QueryTripsResult(header, QueryTripsResult.Status.INVALID_DATE);
                else
                    throw new IllegalStateException("unknown message: " + message);
            }
            XmlPullUtil.skipExit(pp, "itdDate");
        } else {
            XmlPullUtil.next(pp);
        }
        XmlPullUtil.skipExit(pp, "itdDateTime");
        XmlPullUtil.skipExit(pp, "itdTripDateTime");

        XmlPullUtil.requireSkip(pp, "itdTripOptions");
        while (XmlPullUtil.test(pp, "omcTaxi"))
            XmlPullUtil.requireSkip(pp, "omcTaxi");

        final List<Trip> trips = new ArrayList<Trip>();

        XmlPullUtil.require(pp, "itdItinerary");
        if (!pp.isEmptyElementTag()) {
            XmlPullUtil.enter(pp, "itdItinerary");

            XmlPullUtil.optSkip(pp, "itdLegTTs");

            if (XmlPullUtil.test(pp, "itdRouteList")) {
                XmlPullUtil.enter(pp, "itdRouteList");

                final Calendar calendar = new GregorianCalendar(timeZone);

                while (XmlPullUtil.test(pp, "itdRoute")) {
                    final String id;
                    if (useRouteIndexAsTripId) {
                        final String routeIndex = XmlPullUtil.optAttr(pp, "routeIndex", null);
                        final String routeTripIndex = XmlPullUtil.optAttr(pp, "routeTripIndex", null);
                        if (routeIndex != null && routeTripIndex != null)
                            id = routeIndex + "-" + routeTripIndex;
                        else
                            id = null;
                    } else {
                        id = null;
                    }
                    final int numChanges = XmlPullUtil.intAttr(pp, "changes");
                    XmlPullUtil.enter(pp, "itdRoute");

                    while (XmlPullUtil.test(pp, "itdDateTime"))
                        XmlPullUtil.next(pp);
                    XmlPullUtil.optSkip(pp, "itdMapItemList");

                    XmlPullUtil.enter(pp, "itdPartialRouteList");
                    final List<Trip.Leg> legs = new LinkedList<Trip.Leg>();